import cv2
import matplotlib.pyplot as plt
img=cv2.imread('CV-Pictures/gate.jpg')
histb=cv2.calcHist([img],[0],None,[256],[0,255])
histg=cv2.calcHist([img],[1],None,[256],[0,255])
histr=cv2.calcHist([img],[2],None,[256],[0,255])
cv2.imshow('img',img)
plt.plot(histb,color='b',label='blue-hist')
plt.plot(histg,color='g',label='green-label')
plt.plot(histr,'r',label='red-label')
plt.legend(loc='best')
plt.show()
cv2.waitKey()
cv2.destroyAllWindows()